import type {SizeType} from "antd/lib/config-provider/SizeContext";
import type {WritableDraft} from "immer";


export interface useSettersStoreType<T> {
    (nextStateOrUpdater: T | Partial<T> | ((state: WritableDraft<T>) => void)): void
}

export interface useGettersStoreType<T> {
    (): T;

    (): { (): any; new(): any; [x: string]: any[]; };
}

export type GlobalState = {
    componentSize: SizeType;
    compactAlgorithm: boolean;
    borderRadius: number;
    maximize: boolean;
    primary: string;
    isDark: boolean;
    accordion: boolean;
    breadcrumb: boolean;
    breadcrumbIcon: boolean;
    tabs: boolean;
    tabsIcon: boolean;
    tabsDrag: boolean;
}

export declare namespace useGlobalStoreType {
    type stateType = GlobalState
    type storeType = stateType & { setGlobalState: (payload: ObjToKeyValUnion<stateType>) => void }
}

export declare namespace useTabsStoreType {
    interface stateType {
        tabsList: TabsListProp[];
    }

    interface TabsListProp {
        icon: string;
        title: string;
        path: string;
        closable: boolean;
    }

    type storeType = stateType & {
        setTabsList: (tabsList: stateType["tabsList"]) => void
        addTab: (payload: TabsListProp) => void
        removeTab: (payload: { path: string; isCurrent: boolean }) => void
        closeTabsOnSide: (payload: { path: string; type: "left" | "right" }) => void
        closeMultipleTab: (payload: { path?: string }) => void
        setTabTitle: (payload: string) => void
    }
}

export declare namespace useUserStoreType {
    interface stateType {
        token: string,
        userInfo: Record<string, any>,
        authButtonList: string[],
        authRoleList: string[],
    }

    type storeType = stateType & {
        setToken: (token: string) => void,
        signOut: () => void,
        setUserInfo: (payload: Record<string, unknown>) => void,
        setAuthPermission: (payload: Record<string, unknown>) => void,
        setAuthRole: (payload: Record<string, unknown>) => void
    }
}

export declare namespace useMenuStoreType {
    interface stateType {
        flatMenuList: any[],
        menuList: any[],
        menuTree: any[],
        collapsed: boolean
    }

    type storeType = stateType & {
        setCollapsed: (collapsed: boolean) => void
        setAuthMenuList: (menuList: any[]) => void
        clearAuthMenu: () => void
    }
}
